/*
 * Copyright (c) 2008 Benoit Bouchez, Nicolas Giard
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.noocodecommit.wicket.stuff.jquery.plugin.ui.slider;

import com.noocodecommit.wicket.stuff.jquery.plugin.JQPluginOptions;

/**
 * JQSlider Option set
 * 
 * @author Benoit Bouchez
 * 
 */
public class JQSliderOptions extends JQPluginOptions implements Cloneable
{
	/** horizontal axis value */
	public final static String AXIS_HORIZONTAL = "horizontal";
	/** vertical axis value */
	public final static String AXIS_VERTICAL = "horizontal";

	private String handle = ".ui-slider-handle";
	private String handles; // Specify boundaries for one or more handles. Format: {start:Integer, min:Integer, max:Integer, id:String}. Only start is required. If the slider doesn't have handles already, they are automatically created.
	private boolean range = false; // If set to true, the slider will detect if you have two handles and create a stylable range element between these two. You now also have access to ui.range in your callbacks to get the amount of the range.
	private int min = 0;
	private int max = 100;
	private int startValue;
	private int stepping;
	private int steps = 0;
	private String axis;

	private String stopScript = "";
	private String startScript = "";
	private String slideScript = "";
	private String changeScript = "";

	/**
	 * Constructor
	 */
	public JQSliderOptions()
	{
		super();
		this.setDefaultHeader("slider");
	}

	/**
	 * Gets the handle value
	 * 
	 * @return the handle value
	 */
	public String getHandle()
	{
		return handle;
	}

	/**
	 * Sets the handle option value
	 * 
	 * @param handle
	 *            slider handle
	 */
	public void setHandle(String handle)
	{
		this.handle = handle;
		this.options.put("handle", "handle:'" + handle + "'");
	}

	/**
	 * Gets the handles value
	 * 
	 * @return the handles value
	 */
	public String getHandles()
	{
		return handles;
	}

	/**
	 * Sets the handles option value
	 * 
	 * @param start
	 *            handles start
	 * @param min
	 *            handles min
	 * @param max
	 *            handles max
	 * @param id
	 *            handles id
	 */
	public void setHandles(int start, int min, int max, String id)
	{
		this.handles = "{start:" + start + ", min:" + min + ", max:" + max + ", id:'" + id + "'};";
		this.options.put("handles", "handles:" + this.handles);
	}

	/**
	 * Gets the range value
	 * 
	 * @return the range value
	 */
	public boolean isRange()
	{
		return range;
	}

	/**
	 * Sets the range option value
	 * 
	 * @param range
	 *            slider range
	 */
	public void setRange(boolean range)
	{
		this.range = range;
		this.options.put("range", "range:" + range);
	}

	/**
	 * Gets the min value
	 * 
	 * @return the min value
	 */
	public int getMin()
	{
		return min;
	}

	/**
	 * Sets the min option value
	 * 
	 * @param min
	 *            slider min
	 */
	public void setMin(int min)
	{
		this.min = min;
		this.options.put("min", "min:" + min);
	}

	/**
	 * Gets the max value
	 * 
	 * @return the max value
	 */
	public int getMax()
	{
		return max;
	}

	/**
	 * Sets the max option value
	 * 
	 * @param max
	 *            slider max
	 */
	public void setMax(int max)
	{
		this.max = max;
		this.options.put("max", "max:" + max);
	}

	/**
	 * Gets the start value
	 * 
	 * @return the start value
	 */
	public int getStartValue()
	{
		return startValue;
	}

	/**
	 * Sets the start value option value
	 * 
	 * @param startValue
	 *            slider start value
	 */
	public void setStartValue(int startValue)
	{
		this.startValue = startValue;
		this.options.put("startValue", "startValue:" + startValue);
	}

	/**
	 * Gets the stepping value
	 * 
	 * @return the stepping value
	 */
	public int getStepping()
	{
		return stepping;
	}

	/**
	 * Sets the stepping option value
	 * 
	 * @param stepping
	 *            slider stepping
	 */
	public void setStepping(int stepping)
	{
		this.stepping = stepping;
		this.options.put("stepping", "stepping:" + stepping);
	}

	/**
	 * Gets the steps value
	 * 
	 * @return the steps value
	 */
	public int getSteps()
	{
		return steps;
	}

	/**
	 * Sets the steps option value
	 * 
	 * @param steps
	 *            slider steps
	 */
	public void setSteps(int steps)
	{
		this.steps = steps;
		this.options.put("steps", "steps:" + steps);
	}

	/**
	 * Gets the axis value
	 * 
	 * @return the axis value
	 */
	public String getAxis()
	{
		return axis;
	}

	/**
	 * Sets the axis option value
	 * 
	 * @param axis
	 *            slider axis
	 */
	public void setAxis(String axis)
	{
		this.axis = axis;
		this.options.put("axis", "axis:'" + axis + "'");
	}

	/**
	 * Gets the stop script value
	 * 
	 * @return the stop function
	 */
	public String getStopScript()
	{
		return stopScript;
	}

	/**
	 * Sets the stop function
	 * 
	 * @param stopScript
	 *            slider stop function
	 */
	public void setStopScript(String stopScript)
	{
		this.stopScript = stopScript;
		this.options.put("stop", "stop:function(e, ui){" + stopScript + "}");
	}

	/**
	 * Gets the start script value
	 * 
	 * @return the start function
	 */
	public String getStartScript()
	{
		return startScript;
	}

	/**
	 * Sets the start function
	 * 
	 * @param startScript
	 *            slider start function
	 */
	public void setStartScript(String startScript)
	{
		this.startScript = startScript;
		this.options.put("start", "start:function(e, ui){" + startScript + "}");
	}

	/**
	 * Gets the slide script value
	 * 
	 * @return the slide function
	 */
	public String getSlideScript()
	{
		return slideScript;
	}

	/**
	 * Sets the slide function
	 * 
	 * @param slideScript
	 *            slider slide function
	 */
	public void setSlideScript(String slideScript)
	{
		this.slideScript = slideScript;
		this.options.put("slide", "slide:function(e, ui){" + slideScript + "}");
	}

	/**
	 * Gets the change script value
	 * 
	 * @return the change function
	 */
	public String getChangeScript()
	{
		return changeScript;
	}

	/**
	 * Sets the change function
	 * 
	 * @param changeScript
	 *            slider change function
	 */
	public void setChangeScript(String changeScript)
	{
		this.changeScript = changeScript;
		this.options.put("change", "change:function(e, ui){" + changeScript + "}");
	}

	@Override
	protected Object clone() throws CloneNotSupportedException
	{
		JQSliderOptions clone = (JQSliderOptions)super.clone();
		return clone;
	}
}
